<?php
/**
 * Created by PhpStorm.
 * User: xuanqiang
 * Date: 2017/9/6
 * Time: 18:23
 */

class Cspace
{
    /**获取企业下的自定义空间 微应用调用时
     * @param $accessToken
     * @param $agent_id
     * @return mixed
     * {
     * "errcode":0,
     * "errmsg":"ok",
     * "spaceid":"xxxx"
     * }
     */
    public static function getCustomSpace($accessToken, $agent_id)
    {
        $response = Http::get("/cspace/get_custom_space",
            array("access_token" => $accessToken, 'agent_id' => $agent_id));
        return $response;
    }

    /**
     * 授权用户访问企业下的自定义空间
     * @param $accessToken
     * @param $agent_id
     * @param $userid
     * @return bool
     */
    public static function grantCustomSpace($accessToken, $agent_id, $userid)
    {
        $type = 'add';      //权限类型，目前支持上传和下载，上传请传add，下载请传download
        $path = '/';        //授权访问的路径，根目录下上传一个文件为‘/’
        $response = Http::get("/cspace/grant_custom_space",
            array('access_token' => $accessToken, 'agent_id' => $agent_id,
                'type' => $type, 'userid' => $userid, 'path' => $path));
        return $response;
    }
}